
//web 接口设置
void servletSet() {
  server.on("/", HTTP_GET, settingRoot);
  server.on("/wifi_ssids", HTTP_GET, getssids);
  server.on("/wifi_setting", HTTP_POST, settingAndConnection);
  server.on("/status", HTTP_GET, getststus) ;
  server.onNotFound(notFound);
}

void getststus(AsyncWebServerRequest * request)
{
  Serial.println("get  listssids request ....");
  request->send(200, "text/json", WIFI_STATUS_STR);
}


void getssids(AsyncWebServerRequest * request)
{
  Serial.println("get  listssids request ....");
  request->send(200, "text/json", WIFI_SCAN_JSON);
}



void settingAndConnection(AsyncWebServerRequest * request)
{
  Serial.println("get input >>");
  WIFI_STA_SID_VAL = request->arg("sid");
  WIFI_STA_SID_PASS_VAL = request->arg("pass");
  WATHER_KEY=request->arg("w_key");
  WATHER_LOCATION=request->arg("w_loc");
  
  Serial.print ("GET REQUEST WIFI STA INFO >>> STA_SID_VAL >> ");
  Serial.print (WIFI_STA_SID_VAL);
  Serial.print ("   ");
  Serial.print ("STA_SID_PASS_VAL >> ");
  Serial.print (WIFI_STA_SID_PASS_VAL);

  Serial.print ("   ");
  Serial.print ("WATHER_KEY >> ");
  Serial.print (WATHER_KEY);

  Serial.print ("   ");
  Serial.print ("WATHER_LOCATION >> ");
  Serial.print (WATHER_LOCATION);
  Serial.println();

  saveWifiStaJsonConf();
  Serial.println("STA  WIFI保存链接配置完成");
  START_WIFI_STA_CTRL = true;
  request->send(200, "text/json", WIFI_STATUS_STR);
}


void settingRoot(AsyncWebServerRequest *request)
{
  request->send(200, "text/html", SETTING_PAGE);
}


void notFound(AsyncWebServerRequest *request) {
  request->send(404, "text/html", "not found");
}
